package com.order.service;

import com.order.dao.OrderDao;
import com.order.util.CommonResponse;
import com.order.util.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {
    @Autowired
    private TokenUtil tokenUtil;
    @Autowired
    private OrderDao orderDao;
    public CommonResponse get(String token){
        int userId = 0;
        try {
            userId = tokenUtil.getUserId(token);
            return new CommonResponse<List>(200,"ok",orderDao.selectOrder(userId));
        } catch (Exception e) {
            return new CommonResponse<Exception>(500,"fail",e);
        }
    }
}
